package com.kingschan.util.lang;
/**
 * 时间工具类
 * @author kingschan
 *date:2013-6-7
 */
public class DateUtil {

	/**
	 * 程序过行时间差
	 * 两个Long时间之差
	 * @param time
	 * @return
	 */
	public static String runtimeDifference(long time){
		//微秒
		long microsecond=time;
		// 毫秒
		long ssec = time % 1000;
		// 秒
		long sec = (time / 1000) % 60;
		// 分钟
		long min = (time / 1000 / 60) % 60;
		// 小时
		long hour = (time / 1000 / 60 / 60) % 24;
		// 天
		long day = time / 1000 / 60 / 60 / 24;
		if (day > 0) {
			return day + " Day " + hour + " hour " + min + " Minute " + sec + " Second ";
		}
		if (hour > 0) {
			return hour + " hour " + min + " Minute " + sec + " Second ";
		}
		if (min > 0) {
			return min + " Minute " + sec + " Second ";
		}
		if (sec > 0) {
			return  sec + " Second ";
		}
		if (ssec > 0) {
			return  ssec + " Millisecond ";
		}


		return microsecond + " Microseconds ";
	}
}
